/*=======================================================================
 *Subsystem:   no-real-time
 *File:        app.c
 *Author:      ZhangWenbo
 *Description:
 ========================================================================
 * History:
 * 1. Date:2023.09.23
      Author:zhangwenbo
      Modification:1. .
========================================================================*/
#include "task.h"
#include "type.h"
#include "main.h"
#include "stdio.h"
typedef void (*TaskFun)(void);

static void EpyTask(void);

void eSleepTask(void) {

};

void EdisPlayTask(void) {

};
void HeatingControlTask(void) {

};
void MonitorTask(void) {
	printf("MonitorTask\r\n");
};
void KeyTask(void) {

};

typedef struct {
	uint8_t pri;
	uint16_t prod;
	TaskFun handle;
} TaskInf_t;

static const TaskInf_t gTaskInf[REAL_NUM_TASK] = {
	{
		0,
		1000,
		EpyTask,
	},
	{
		1,
		100,
		EdisPlayTask, /**显示任务**/
	},
	{
		2,
		10,
		HeatingControlTask, /**加热任务**/
	},
	{
		3,
		200,
		eSleepTask, /**睡眠任务**/
	},
	{
		4,
		2000,
		MonitorTask, /**监控任务**/
	},
	{
		5,
		50,
		KeyTask, /**按键任务**/
	},
};
uint8_t gTaskState[MAXNUMTASK];
/*=======================================================================
 *function: static void EpyTask(void)
 *parameter:
 *return:
 *describe: empty task
========================================================================*/
static void EpyTask(void) {
}
/*=======================================================================
 *function: void APPTask_Creat(void)
 *parameter:
 *return:
 *describe: create app task and idle task
========================================================================*/
void AppTaskCreate(void) {
	uint8_t i;

#if SYSTASK_SWITCH == OFF_SYSTEST
	gTaskState[IDLETASK_PRIO] = TaskCreate(TaskIdle, IDLETASK_PRIO, 0, 0);
#endif

	for (i = 1; i < REAL_NUM_TASK; i++) {
		if (gTaskInf[i].handle != EpyTask) {
			gTaskState[i] = TaskCreate(gTaskInf[i].handle, gTaskInf[i].pri, gTaskInf[i].prod, gTaskInf[i].pri * 10);
		}
	}
}
/*=======================================================================
 *function: void ProjectTaskCreat(void)
 *parameter:
 *return:
 *describe: if detect app task cpu coefficient, it need to open SYSTASK_SWITCH = ON_SYSTEST.
========================================================================*/
void ProjectTaskCreat(void) {
#if SYSTASK_SWITCH == ON_SYSTEST
	gTaskState[IDLETASK_PRIO] = TaskCreate(TaskIdle, IDLETASK_PRIO, 0, 0);    /* idle task */
	gTaskState[STATTASK_PRIO] = TaskCreate(TaskStat, STATTASK_PRIO, 1000, 0); /* statistics task */
#else
	AppTaskCreate();
#endif
}
/*=======================================================================
========================================================================*/
